package esms.cases;

import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;

import com.thoughtworks.selenium.DefaultSelenium;

import esms.action.ActionFactory;
import esms.action.ActionInterface;
import esms.manager.RunTimeContext;


public abstract class BaseCase extends AbstractCase{
	protected static ActionInterface initBrowser;
	private static String browser  = "*firefox";
	private static String url =	"http://localhost:8080/ESMS";
	public static String TIME_OUT = "100000";
	
	@BeforeSuite
	@Parameters( { "browser","url"})
	public void initCases(@Optional("*firefox")String browser,@Optional("http://localhost:8080/ESMS")String url){
		this.browser = browser;
		this.url = url;
		initActions();
		initBrowser.execute(null); // start the browser
	}
	
	@AfterSuite
	public void finalizeCases(){
		//closeBrowser();
	}
	
	private static void initActions() {
		initBrowser = ActionFactory.getInitBrowserAction(
				url, browser,
				TIME_OUT, RunTimeContext.ESMS);
		/*
		waitForGeneralInfoPage = CommonActionFactory
				.getWaitForElementPresentAction(
						DWCClientConstants.GENERAL_INFO_TITLE,
						DWCClientConstants.PAUSE_LONG);
		 */
	}
	
	public DefaultSelenium getBrowser() {
		return RunTimeContext.getBrowser(RunTimeContext.ESMS);
	}
	
	public static String getUrl() {
		return url;
	}
}
